import MySQLdb

# 设置数据库连接字符串，包括连接地址，用户名，密码和还要连接的数据库名
my_connection = MySQLdb.connect("localhost", "root", "20050526", "cake_shop")

# 获取数据库连接的游标对象
cursor = my_connection.cursor()


def test():
    cursor.execute("SELECT * FROM tb_cake")
    results = cursor.fetchall()
    for row in results:
        print(row)


if __name__ == '__main__':
    test()
